# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=sphinxcontrib-github-alt
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.2
pkgrel=4
pkgdesc="Link to GitHub issues, pull requests, commits and users from Sphinx docs. (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url='https://github.com/jupyter/sphinxcontrib_github_alt'
license=('spdx:BSD-2-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-docutils"
         "${MINGW_PACKAGE_PREFIX}-python-sphinx")
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-python-build"
  "${MINGW_PACKAGE_PREFIX}-python-installer"
  "${MINGW_PACKAGE_PREFIX}-python-flit-core")
source=("${_realname}-${pkgver}.tar.gz"::"$url/archive/refs/tags/${pkgver}.tar.gz")
sha256sums=('7a85ad988f7b7cdc230d58854c31acab1308a75016b9c453bf76bfc0598cbbac')

build() {
  cd "${srcdir}"
  cp -r "${_realname//-/_}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"

  python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    python -m installer --prefix=${MINGW_PREFIX} --destdir="${pkgdir}" dist/*.whl

  install -Dm644 COPYING.md "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
